package com.sx.zongzhi.adapter;


import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sx.zongzhi.R;
import com.sx.zongzhi.bean.MailBean;
import com.sx.zongzhi.utils.BaseUtil;

import java.util.List;

/**
 * Created by XZY on 2017/11/22.
 * 收件箱adapter
 */

public class MailAdapter extends BaseQuickAdapter<MailBean,BaseViewHolder> {

    private Context context;

    public MailAdapter(Context context, @LayoutRes int layoutResId, @Nullable List<MailBean> data) {
        super(layoutResId, data);
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolder helper, MailBean item) {
        TextView sender = helper.getView(R.id.tv_Name);
        TextView sendDate = helper.getView(R.id.tv_Time);
        TextView title = helper.getView(R.id.tv_Title);
        TextView content = helper.getView(R.id.tv_Content);
        if (sender != null){
            if (!BaseUtil.isEmpty(item.sender)){
                sender.setText(item.sender);
            }
        }
        sendDate.setText(item.sendDate);
        title.setText(item.title);
        content.setText(item.content);
        if (item.readState == 1){//阅读状态(0:未读,1:已读)
            if (sender != null){
                sender.setTextColor(context.getResources().getColor(R.color.c_999999));
            }
            sendDate.setTextColor(context.getResources().getColor(R.color.c_999999));
            title.setTextColor(context.getResources().getColor(R.color.c_999999));
            content.setTextColor(context.getResources().getColor(R.color.c_999999));
        }else {
            if (sender != null){
                sender.setTextColor(context.getResources().getColor(R.color.black));
            }
            sendDate.setTextColor(context.getResources().getColor(R.color.black));
            title.setTextColor(context.getResources().getColor(R.color.black));
            content.setTextColor(context.getResources().getColor(R.color.black));
        }
    }
}
